import { FC, ReactElement } from "react";
import { Navigate } from "react-router-dom";

interface Props {
  children: ReactElement;
}
const Index: FC<Props> = ({ children }) => {
  // 1 获取
  const userinfo = localStorage.getItem("userinfo");
  // 2 判断
  if (userinfo) {
    return <>{children}</>;
  } else {
    return <Navigate to="/login" />;
  }
};

export default Index;
